﻿using Newtonsoft.Json;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Text;
using System.Web;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Markup;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using static System.Net.Mime.MediaTypeNames;
using static System.Net.WebRequestMethods;

namespace WpfAppTool
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
       
        public MainWindow()
        {           
            InitializeComponent();
           
            //// 设置请求头
            //_httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", _token);
        }

        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            string token = "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJsb2dpbl91c2VyX25hbWUiOiLmuLjlrqIgMTU5MjQxODQzNzciLCJsb2dpbl9leHBpcmVkX3RpbWUiOjE3NDU0OTc4ODU3NjIsImxvZ2luX3VzZXJfaWQiOjE2MTAwODY0LCJsb2dpbl91c2VyX2tleSI6IjE2MTAwODY0OmYwNDllNGJlLTJjYzItNDg3ZS1iZDI0LWUxOTBmMjc1YjhkZCIsImxvZ2luX3VzZXJfYWNjb3VudCI6IjE1OTI0MTg0Mzc3In0.Z9M50Uxtth0D2cRny_AjDs2AeAlhe_70BOFQUQ1LKWM";

            var obj = new Ticket();
            obj.date = "2025-04-24";


            List<ticketInfo> lst = new List<ticketInfo>();
            lst.Add(new ticketInfo() { userName = "艾家林", certificateInfo = "340222196408262018", hallScheduleId = 2, useDate =DateTime.Parse(obj.date).ToString("yyyy-MM-dd 00:00:00")  });
            //lst.Add(new ticketInfo() { userName = "456", certificateInfo = "test2", hallScheduleId = 2, useDate = DateTime.Parse(obj.date).ToString("yyyy-MM-dd 00:00:00") });
            obj.ticketNum = lst.Count;
            obj.ticketInfoList = lst;
            var _httpClient = new HttpClient();
            _httpClient.DefaultRequestHeaders.Add("xweb_xhr", "1");
            //_httpClient.DefaultRequestHeaders.Add("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36 MicroMessenger/7.0.20.1781(0x6700143B) NetType/WIFI MiniProgramEnv/Windows WindowsWechat/WMPF WindowsWechat(0x63090c33)XWEB/11581");
            string url = "https://sensorsdata.chnmuseum.cn/sa?project=production";
            var json = "data_list=W3siZGlzdGluY3RfaWQiOiIxODA0MjQ2OTg4MCIsImlkZW50aXRpZXMiOnsiJGlkZW50aXR5X21wX2lkIjoiMTc0NTQyMDE1NTUwMS0xNDk2MDEzLTBhNzQyYTZiYmNkYjY4OC0zNzQzNjAyNiIsIiRpZGVudGl0eV9sb2dpbl9pZCI6IjE4MDQyNDY5ODgwIiwiJGlkZW50aXR5X2Fub255bW91c19pZCI6Im9zUGZONHVsME5YNjNZNVJ6V0VoY0xwbGJOVVkiLCIkaWRlbnRpdHlfbXBfd3g5ZTI5MjdkZDU5NWIwNDczX29wZW5pZCI6Im9zUGZONHVsME5YNjNZNVJ6V0VoY0xwbGJOVVkifSwibGliIjp7IiRsaWIiOiJNaW5pUHJvZ3JhbSIsIiRsaWJfbWV0aG9kIjoiY29kZSIsIiRsaWJfdmVyc2lvbiI6IjEuMTcuNSJ9LCJwcm9wZXJ0aWVzIjp7IiRsaWIiOiJNaW5pUHJvZ3JhbSIsIiRsaWJfdmVyc2lvbiI6IjEuMTcuNSIsIiRuZXR3b3JrX3R5cGUiOiJXSUZJIiwiJGJyYW5kIjoiTUlDUk9TT0ZUIiwiJG1hbnVmYWN0dXJlciI6Im1pY3Jvc29mdCIsIiRtb2RlbCI6Im1pY3Jvc29mdCIsIiRzY3JlZW5fd2lkdGgiOjQxNCwiJHNjcmVlbl9oZWlnaHQiOjc4MCwiJG9zIjoid2luZG93cyIsIiRvc192ZXJzaW9uIjoiMTAiLCIkbXBfY2xpZW50X2FwcF92Z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VycmVyIjoic3ViUGFnZXMvdGlja2V0L3BlcnNvbmFsL2ZpbGxJbmZvL2ZpbGxJbmZvIiwiJHJlZmVycmVyX3RpdGxlIjoi6aKE57qm5pyN5Yqh57O757ufIiwiJHRpdGxlIjoi6aKE57qm5pyN5Yqh57O757ufIiwiJGlzX2ZpcnN0X2RheSI6dHJ1ZSwiJHVybCI6InN1YlBhZ2VzL3RpY2tldC9wZXJzb25hbC9jb25maXJtL2NvbmZpcm0ifSwibG9naW5faWQiOiIxODA0MjQ2OTg4MCIsImFub255bW91c19pZCI6Im9zUGZONHVsME5YNjNZNVJ6V0VoY0xwbGJOVVkiLCJ0eXBlIjoidHJhY2siLCJldmVudCI6IiRNUFZpZXdTY3JlZW4iLCJfdHJhY2tfaWQiOjU0ODE2NTIyLCJ0aW1lIjoxNzQ1NDIwMzI2NTIyLCJfZmx1c2hfdGltZSI6MTc0NTQyMDMzMDk3OH1d";
            var content = new StringContent(json, Encoding.UTF8, "application/json");
            var response = await _httpClient.PostAsync(url, content);
            if (response.IsSuccessStatusCode)
            {
                _httpClient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
              
                url = "https://wxmini.chnmuseum.cn/prod-api/config/orderRule/checkLeaderInfo";
                json = JsonConvert.SerializeObject(obj);
                content = new StringContent(json, Encoding.UTF8, "application/json");
                response = await _httpClient.PostAsync(url, content);
                if (response.IsSuccessStatusCode)
                {
                    response.EnsureSuccessStatusCode();

                    var rspcontent = await response.Content.ReadAsStringAsync();
                }

                /*
                请求这个  https://flysec.m.qq.com/jprx/1941

                 
                 */

                _httpClient.DefaultRequestHeaders.Add("host-ip","3YnPjJul0z0oLIbvzA+qzA==");

                /*
                 {
    "useTicketType": 1,
    "poolFlag": 1,
    "realNameFlag": 1,
    "platform": 2,
    "ticketNum": 1,
    "date": "2025-04-24",
    "childTicketNum": 0,
    "saleMode": 1,
    "pointJson": "P7WAF1xMmg2y601ExYdrkzH0DSEKLAEMG8Njbuq/55dxdHaF/wwvR0Dw0XqBOCf0",
    "captchaToken": "9548449447714839918cc7f04914b016-23723519-1745420433176",
    "scanToken": null,
    "ticketInfoList": [
        {
            "status": 0,
            "saleMode": 1,
            "platform": 2,
            "hallId": 1,
            "hallScheduleId": 2,
            "cinemaFlag": 0,
            "ticketPriceId": 8,
            "certificate": "1",
            "certificateInfo": "620422199309076430",
            "userName": "林宠",
            "useDate": "2025-04-24 00:00:00",
            "isChildFreeTicket": 0,
            "realNameFlag": 1
        }
    ],
    "deviceToken": "v2:9akBWC89ddhDb9Ad1r+SVcP26bqRoLaKyB48jutIXTTNrq/vc5PG+1WEyZhNvpQZocqzyaZ0CxuZe5+EgfxgTK9nBWHWQFzsrpSpkv1SV8FEaEIGmN68O0yutr4hPZ1Pd2J36tj7k/4K144+X8lOVCswqlyFoAy3CvxmmwtD69XnMge2fMaW/E9RdqqQPvnXqqt47Egi/FfSAEC4Kkb4q8JohgFBD6WikMR3P3MHLW/HSkujstWUBFLzGKdpbv+4Rk1EDgxAG/ohzR1L3vIrb+LYnzOftMJzgsbgsCiDn/bYP6x7fMtp",
    "p": "wxmini"
}

                 
                 
                 
                 
                 */

                url = "https://wxmini.chnmuseum.cn/prod-api/config/orderRule/placeOrder";//提交接口

                /*******
                 * {
                    "msg": "操作成功",
                    "code": 200,
                    "data": {
                        "orderRealPrice": 0.00,
                        "orderNumber": "SK25042323473581",
                        "riskEnable": false,
                        "createTime": "2025-04-23 23:00:35",
                        "orderId": 23473581,
                        "schduleDate": "2025-04-24 11:00-13:30",
                        "needChargeCode": 0
                    }
                 }
                 * 
                 * 
                 * 
                 * 
                 * 
                 * ******/
            }

            //var json = JsonConvert.SerializeObject(data);
            //var content = new StringContent(json, Encoding.UTF8, "application/json");

            //var response = await client.PostAsync("https://httpbin.org/post", content);
            //var result = await response.Content.ReadAsStringAsync();
        }
    }
}